package ru.mcfr.oxygen.framework.extensions;

import ro.sync.ecss.extensions.api.AttributesValueEditor;
import ro.sync.ecss.extensions.api.EditedAttribute;
import ro.sync.ui.AbstractFileChooser;
import ro.sync.ui.FileChooserSingleton;

/**
 * Simple Document Framework attributes value editor.
 */
public class MOFAttributesValueEditor implements AttributesValueEditor {
    /**
     * Get the value for the current attribute.
     *
     * @param arg0 The Edited attribute information.
     * @param arg1 The parent component/composite.
     */
    public String getAttributeValue(EditedAttribute arg0, Object arg1) {
        if (arg0.getAttributeQName().endsWith("ref")) {
            AbstractFileChooser fc = FileChooserSingleton.getAbstractFileChooserInstance();
            if (fc.showOpenDialog() == 0) {
                return fc.getSelectedFile().getAbsolutePath();
            }
        }
        return null;
    }
}